package com.jqr.activity.mykotlinbase

import java.util.Locale

data class Test(val id:Int,val name:String)

fun  main(){
    val  test= listOf(1,3,5,7,9)
    println("大于5的数：${test.filter { it>=5 }}")
    println("平方操作：${test.map { it*it }}")

    val  testListOf= listOf(Test(1,"Rose"),Test(2,"Jordan"), Test(3,"Marcel"))
    println("显示Name ${testListOf.map { it.name }}")
    println("id>1 ${testListOf.filter { it.id>1 }.map { it.name }}")




}
//定义Person类
//参数默认值
class Person(firstName:String="John",lastName:String="rose"){

    init {
        println("Person created firstName:$firstName,lastName:$lastName")
    }
    var age:Int?=null;


    var  hobby:String=" play footall"


    constructor(firstName:String,lastName:String,age: Int):this(firstName,lastName){
        this.age=age;
    }


    fun  statHobby(){

        println("my Hobby $hobby")
    }



}

class Car(){
    lateinit var owner:String;

    val myBoard:String="BMW"
        get(){
            return  field.lowercase()
        };
    var maxSpeed:Int=120
        get()=field
        set(value){
            field=value
        };
    var  color:String="white"
        get() = field
        set(value){
            field=value
        }

    init {
        this.owner="me"
    }
}
//readonly
data class User(val id:Long,val name:String)
// readOnly writtern
data class User1(var id:Long,var name:String)


// open 公开类，能够集成
open class Animal(override val maxSpeed: Double) :Drivable{
    override fun drive(): String {
        TODO("Not yet implemented")
    }

}

class Bird(maxSpeed: Double) :Animal(maxSpeed){

}

interface  Drivable{
    val maxSpeed:Double;
    fun  drive():String;
    fun  brake(){
        println( "driver is brake")
    }
}